import { ElMessage } from "element-plus";
import * as Api from '@/api/configCenter/configCenter';
import type { CallBackData } from '@/components/dialog/type.d';
type DataInfo = {
  visible: boolean;
  title: string;
  width: number;
  isForm: boolean;
  maskClosable: boolean;
  okText: string;
  modalClass: string;
  footer: boolean;
  hideCancel: boolean;
  modelForm: any;
}
export const saveInterface = async (dataInfo: DataInfo, modalData: CallBackData): Promise<boolean> => {
  let returnFlag = false;
  try {
    const params = {
      id: dataInfo.modelForm.id,
      name: dataInfo.modelForm.name,
      remark: dataInfo.modelForm.remark,
    }
    const res = await Api.updateTool(params);
    if (res.code === 200) {
      ElMessage.success("编辑成功！");
      dataInfo.visible = modalData.flag;
      returnFlag = true;
    }
  } catch (error) {
    console.log(error);
    dataInfo.visible = true;
  }
  return returnFlag;
}